package com.aaa.commonmethods;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description:
 *       public final void join()
 *       允许其他线程加入到当前线程中，直到其他线程执行完毕后，当前线程才会执行
 * @date 2022/11/1
 */
public class JoinDemo extends Thread{
    @Override
    public void run() {
        super.run();
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"~~~~~"+i);
        }
    }
}
class Test02{
    public static void main(String[] args) {

        JoinDemo joinDemo = new JoinDemo();
        JoinDemo joinDemo1 = new JoinDemo();
        joinDemo.start();
        joinDemo1.start();
        try {
            joinDemo.join();
            joinDemo1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //joinDemo线程执行完成只会才会执行main

        for (int i = 0; i < 10; i++) {
            System.out.println("main-----------"+i);
        }
    }
}